//需要jQuery 和cookie
//调用getResult方法获取结果

/*

/*
/**
     * 查询订单详情列表
     * @param orderNum
     * @param token
     * @return
     * @throws Exception


public Dto<Map<String,Object>> queryOrderDetailsList(@RequestParam("orderNum")String orderNum, @RequestHeader String token) throws Exception {
 */


var User={
    OrderInfoById:{
        data:null,
        execution:function (orderNum) {
            $.ajax({
                headers:{
                    token:getCookie("token")//getCookie("token")
                },
                url: 'http://cn.pn.com/api-pn/order/api/v/queryOrderDetailsList?=678049222179688448',
                dataType:"json",
                async:false,
                type: 'post',
                data:{orderNum:orderNum},
                success: function (data) {
                    User.OrderInfoById.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.OrderInfoById.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.OrderInfoById.data;
            User.OrderInfoById.data=null;
            return data;
        }
    },
    myOrder:{
        data:null,
        execution:function (orderStatus) {
            $.ajax({
                headers:{
                    token:getCookie("token")//getCookie("token")
                },
                url: 'http://cn.pn.com/api-pn/order/api/v/queryOrderList',
                dataType:"json",
                async:false,
                type: 'post',
                data:{orderStatus:orderStatus},
                success: function (data) {
                    User.myOrder.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.myOrder.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.myOrder.data;
            User.myOrder.data=null;
            return data;
        }
    },
    getUserInfo:{
        data:null,
        execution:function () {
             $.ajax({
                 headers:{
                     token:getCookie("token")
                 },
                 url: 'http://cn.pn.com/api-pn/user/user/v/findUserInfo',
                 dataType:"json",
                 async:false,
                 type: 'post',
                 success: function (data) {
                    User.getUserInfo.data=data;
                 },
                 error: function (response) {
                     console.log(response);
                     User.getUserInfo.data="执行异常";
                 }
             });
         },
        getResult:function () {
            var data=User.getUserInfo.data;
            User.getUserInfo.data=null;
            return data;
        }

    } ,
    logout:{
        data:null,
        execution:function(){
            $.ajax({
                headers:{
                    token:getCookie("token")
                },
                url: 'http://cn.pn.com/api-pn/user/user/v/logout',
               dataType:"json",
                async:false,
                type: 'post',
                success: function (data) {
                    User.logout.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.logout.data="执行异常";
                }
            });
        },
        getResult:function(){
            var data=User.logout.data;
            /*while (data==null){
                if(data==null)
                    data=User.logout.data;
                else
                    break;
            }*/
            User.logout.data=null;
            return data;
        }
    },
    changePwd:{
        data:null,
        execution:function (oidPwd,newPwd,newPwd2) {
            $.ajax({
                headers:{
                    token:getCookie("token")
                },
                url: 'http://cn.pn.com/api-pn/user/user/v/changePwd',
               dataType:"json",
                async:false,
                type: 'post',
                data:{oidPwd:oidPwd,newPwd:newPwd,newPwd2:newPwd2},
                success: function (data) {
                    User.changePwd.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.changePwd.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.changePwd.data;
            User.changePwd.data=null;
            return data;
        }
    },
    register:{
        data:null,
        execution:function (phone,YZM,pwd) {
            $.ajax({
                url: 'http://cn.pn.com/api-pn/user/user/p/register',
               dataType:"json",
                async:false,
                type: 'post',
                data:{phone:phone,YZM:YZM,pwd:pwd},
                success: function (data) {
                    User.register.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.register.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.register.data;
            User.register.data=null;
            return data;
        }
    },
    sendMessage:{
        data:null,
        execution:function (phone,isRegister) {
            $.ajax({
                url: 'http://cn.pn.com/api-pn/user/user/p/sendMessage',
               dataType:"json",
                async:false,
                type: 'post',
                data:{phone:phone,isRegister:isRegister},
                success: function (data) {
                    User.sendMessage.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.sendMessage.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.sendMessage.data;
            User.sendMessage.data=null;
            return data;
        }
    },
    changeBaseUserInfo:{
        data:null,
        execution:function (headImgURL,nickName,signature) {
            $.ajax({
                headers:{
                    token:getCookie("token")
                },
                url: 'http://cn.pn.com/api-pn/user/user/v/changeBaseUserInfo',
               dataType:"json",
                async:false,
                type: 'post',
                data:{headImgURL:headImgURL,nickName:nickName,signature:signature},
                success: function (data) {
                    User.changeBaseUserInfo.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.changeBaseUserInfo.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.changeBaseUserInfo.data;
            User.changeBaseUserInfo.data=null;
            return data;
        }
    },
    fastLogin:{
        data:null,
        execution:function (phone,YZM) {
            $.ajax({
                url: 'http://cn.pn.com/api-pn/user/user/p/fastLogin',
               dataType:"json",
                async:false,
                type: 'post',
                data: {phone:phone,YZM:YZM},
                success: function (data) {
                    User.fastLogin.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.fastLogin.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.fastLogin.data;
            User.fastLogin.data=null;
            return data;
        }
    },
    login:{
        data:null,
        execution:function (phone,userPwd) {
            $.ajax({
                url: 'http://cn.pn.com/api-pn/user/user/p/login',
               dataType:"json",
                async:false,
                type: 'post',
                data: {telephone:phone,userPwd:userPwd},
                success: function (data) {
                    User.login.data=data;
                },
                error: function (response) {
                    console.log(response);
                    User.login.data="执行异常";
                }
            });
        },
        getResult:function () {
            var data=User.login.data;
            User.login.data=null;
            return data;
        }
    },
    address:{
        add:{
            data:null,
            execution:function (receiveName,telephone,receiveAddress,provinceId,cityId,countyId) {
                $.ajax({
                    headers:{
                        token:getCookie("token")//getCookie("token")
                    },
                    url: 'http://cn.pn.com/api-pn/base/address/v/add',
                    dataType:"json",
                    async:false,
                    type: 'post',
                    data: {receiveName:receiveName,telephone:telephone,receiveAddress:receiveAddress,provinceId:provinceId,cityId:cityId,countyId:countyId},
                    success: function (data) {
                        User.address.add.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.address.add.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.address.add.data;
                User.address.add.data=null;
                return data;
            }
        },
        findAll:{
            data:null,
            execution:function () {
                $.ajax({
                    headers:{
                        token:getCookie("token")//getCookie("token")
                    },
                    url: 'http://cn.pn.com/api-pn/base/address/v/select',
                    dataType:"json",
                    async:false,
                    type: 'post',
                    data: {},
                    success: function (data) {
                        User.address.findAll.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.address.findAll.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.address.findAll.data;
                User.address.findAll.data=null;
                return data;
            }
        },
        remove:{
            data:null,
            execution:function (addressId) {
                $.ajax({
                    headers:{
                        token:getCookie("token")//getCookie("token")
                    },
                    url: 'http://cn.pn.com/api-pn/base/address/v/remove',
                   dataType:"json",
                    async:false,
                    type: 'post',
                    data: {addressId:addressId},
                    success: function (data) {
                        User.address.remove.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.address.remove.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.address.remove.data;
                User.address.remove.data=null;
                return data;
            }
        }

    },
    attention:{
        add:{
            data:null,
            execution:function (attentionId,commdityId) {
                $.ajax({
                    url: 'http://cn.pn.com/api-pn/user/attention/v/add',
                   dataType:"json",
                    async:false,
                    type: 'post',
                    data: {attentionId:attentionId,commdityId:commdityId},
                    success: function (data) {
                        User.attention.add.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.attention.add.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.attention.add.data;
                User.attention.add.data=null;
                return data;
            }
        },
        find:{
            data:null,
            execution:function (status) {
                $.ajax({
                    headers:{
                        token:getCookie("token")
                    },
                    url: 'http://cn.pn.com/api-pn/user/attention/v/find',
                   dataType:"json",
                    async:false,
                    type: 'post',
                    data: {status:status},
                    success: function (data) {
                        User.attention.find.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.attention.find.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.attention.find.data;
                User.attention.find.data=null;
                return data;
            }
        },
        remove:{
            data:null,
            execution:function (attentionId,commodityId) {
                $.ajax({
                    headers:{
                        token:getCookie("token")//getCookie("token")
                    },
                    url: 'http://cn.pn.com/api-pn/user/attention/v/remove',
                   dataType:"json",
                    async:false,
                    type: 'post',
                    data: {attentionId:attentionId,commodityId:commodityId},
                    success: function (data) {
                        User.attention.remove.data=data;
                    },
                    error: function (response) {
                        console.log(response);
                        User.attention.remove.data="执行异常";
                    }
                });
            },
            getResult:function () {
                var data=User.attention.remove.data;
                User.attention.remove.data=null;
                return data;
            }
        }
    }
};



